package BinaryTree;
/*
  验证二叉搜索树
 */
import BinaryTree.init.TreeNode;

public class lc98 {

    TreeNode pre = null;

    public boolean isValidBST(TreeNode root) {
        if (root == null) return true;
        boolean lef = isValidBST(root.left);
        if (pre != null && pre.val >= root.val) {
            return false;
        }
        pre = root;
        boolean rig = isValidBST(root.right);
        return lef && rig;
    }

}
